<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateBizPayRecordTableMigration extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change(): void
    {
        $this->table('biz_pay_record', ['id' => false, 'primary_key' => ['id']])
            ->addColumn('id', 'integer', ['limit' => 11, 'null' => false, 'identity' => true])
            ->addColumn('user_id', 'integer', ['limit' => 11, 'null' => false, 'comment' => '用户ID'])
            ->addColumn('biz_id', 'string', ['limit' => 255, 'null' => false, 'comment' => '订单ID'])
            ->addColumn('pay_price', 'decimal', ['limit' => 10, 'null' => false, 'comment' => '金额（不含优惠）', 'default' => 0.00, 'precision' => 10, 'scale' => 2])
            ->addColumn('pay_money', 'decimal', ['limit' => 10, 'null' => false, 'comment' => '实付金额（含优惠）', 'default' => 0.00, 'precision' => 10, 'scale' => 2])
            ->addColumn('pay_status', 'integer', ['limit' => 1, 'null' => false, 'comment' => '支付状态'])
            ->addColumn('paid_at', 'integer', ['limit' => 11, 'null' => false, 'comment' => '支付时间'])
            ->addColumn('money', 'decimal', ['limit' => 11, 'null' => false, 'comment' => '支付差额', 'default' => 0.00, 'precision' => 10, 'scale' => 2])
            ->addColumn('score', 'integer', ['limit' => 11, 'null' => false, 'comment' => '云豆数量'])
            ->addColumn('created_at', 'integer', ['limit' => 11, 'null' => false, 'comment' => '创建时间'])
            ->addColumn('updated_at', 'integer', ['limit' => 11, 'null' => false, 'comment' => '更新时间'])
            ->create();
    }
}
